package org.example;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;

public class Swing_2 {
    public static void main(String[] args) throws ParseException, IOException {
        JFrame jFrame = new JFrame("四川师范大学学生管理系统");//创建窗口
        jFrame.setSize(800,450);//设置窗口大小
        //图标对象来源
        InputStream im = Demo2.class.getClassLoader().getResourceAsStream("1.png");
        BufferedImage image = ImageIO.read(im);
        //设置图标
        jFrame.setIconImage(image);
        //设置窗口可见
        //页面居中
        jFrame.setLocationRelativeTo(null);
        //关闭窗口并且停止运行  常量的规则是 全部大写 并且是接口
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //按钮设置
//        JButton jButton1 = new JButton("保存");
//        jButton1.setFont(new Font("微软雅黑",Font.BOLD,25));
//        jFrame.add(jButton1);

        //文本提示框
        JLabel jLabel = new JLabel("用户名");//用户名
        int value = Spring.width(jLabel).getValue();
        SpringLayout layout = new SpringLayout();
        JPanel jPanel = new JPanel(layout);
        layout.putConstraint(SpringLayout.WEST,jLabel,120,SpringLayout.WEST,jPanel);
        layout.putConstraint(SpringLayout.NORTH,jLabel,120,SpringLayout.NORTH,jPanel);
        //文本输入框
        JTextField jTextField = new JTextField();
        jTextField.setPreferredSize(new Dimension(200,20));
        layout.putConstraint(SpringLayout.WEST,jTextField,value+20,SpringLayout.WEST,jLabel);
        layout.putConstraint(SpringLayout.NORTH,jTextField,120,SpringLayout.NORTH,jPanel);



        jPanel.add(jTextField);
        jPanel.add(jLabel);
        jFrame.add(jPanel);
        jFrame.setVisible(true);
    }
}
